package com.appbase.custom.base;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Describe:
 * Created by Rance Rang on 2019/5/28.
 * <p>
 * Copyright (c) Tange.Inc All rights reserved.
 */
public class AiSeviceInfo implements Parcelable {
    public  String  assay_type;
    public  long expiration_time;
    public  String  type;
    public boolean about_to_expire;
    public  int  save_days;
    public String level;
    public int is_free;
    public  AiSeviceInfo(){

    }

    protected AiSeviceInfo(Parcel in) {
        assay_type = in.readString();
        expiration_time = in.readLong();
        type = in.readString();
        about_to_expire = in.readByte() != 0;
        save_days = in.readInt();
        level = in.readString();
        is_free = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(assay_type);
        dest.writeLong(expiration_time);
        dest.writeString(type);
        dest.writeByte((byte) (about_to_expire ? 1 : 0));
        dest.writeInt(save_days);
        dest.writeString(level);
        dest.writeInt(is_free);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<AiSeviceInfo> CREATOR = new Creator<AiSeviceInfo>() {
        @Override
        public AiSeviceInfo createFromParcel(Parcel in) {
            return new AiSeviceInfo(in);
        }

        @Override
        public AiSeviceInfo[] newArray(int size) {
            return new AiSeviceInfo[size];
        }
    };

    public  boolean isSimCloud(){
        return !TextUtils.isEmpty(level)&&TextUtils.equals(level,"2");
    }
    public boolean isExpireing(){
        long last7Day = System.currentTimeMillis()/1000+24*60*60*7;
       return expiration_time<last7Day;
    }
    public boolean isFree(){
        return is_free==1;
    }
}
